<template>
	<view class="container-shop"
		style="background: url(/static/imgbgc.png) no-repeat; background-size: 100%;height: 100%;">
		<scroll-view scroll-y="true" class="main">
			<!-- <view class="content"> -->
					<swiper class="swiper" circular indicator-dots autoplay :interval="5000"
						indicator-active-color="#fff" :duration="500" style="height: 480rpx;">
						<swiper-item v-for="item in imageList" :key="item.src">
							<view class="" style="height: 100%;">
								<image style="width: 100%;height: 100%" :src="item.image" mode=""></image>
							</view>
						</swiper-item>
					</swiper>
			<!-- </view> -->
			<view class="shopBox" v-if="goodsList">
				<view class="">
					<u-sticky>
						<u-tabs :list="typeList" @change="change" :activeStyle="{
							color: '#fff',fontWeight: 'bold',transform: 'scale(1.05)'}" :inactiveStyle="{
								color: '#dde1ea',
								transform: 'scale(1)'}"></u-tabs>
					</u-sticky>
				</view>
				<view class="shopList">
					<view class="shop-item" v-for="(item,index) in goodsList" :key="index"
						@tap="$fun.jump(`/pageC/shopDetail/shopDetail?ids=${item.id}`)">
						<view class="image">
							<image style="width: 100%;height: 330rpx;" :src="item.image" mode=""></image>
						</view>
						<view class="shop-title">
							<h3>{{item.name}}</h3>
							<view class="bottom">
								<view class="left">
									<text>$</text>
									<text class="price">{{item.money}}</text>
								</view>
								<view class="right">
									{{item.stock}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="" style="margin: 50rpx; 0">
					<u-loadmore loadmoreText="没有更多了" dashed line />
				</view>
			</view>

		</scroll-view>
		<!-- <appUpdate v-if="appUpdateShow" :update_info="update_info" @closeModel="closeModel"></appUpdate> -->
		<TabBar :tabBarShow="2"></TabBar>
	</view>
</template>

<script>
	import appUpdate from "@/components/yzhua006-update/app-update.vue";
	import headerTop from "@/components/dacizi-headtag/dacizi-headtag.vue"
	// import zetankSwiper from "@/component、s/zetank-swiper/components/zetank-swiper/zetank-swiper.vue"
	import {
		checkUpdate
	} from "@/components/yzhua006-update/js/app-update-check.js";
	export default {
		components: {
			headerTop,
			// zetankSwiper,
			appUpdate
		},
		data() {
			return {
				tab_title: "云算能",
				appUpdateShow: false,
				update_info: {},
				imageList: [],
				newsList: [],
				classList: [],
				product: [],
				tabList: [],
				tabIndex: 0,
				typeList: [],
				goodsList: [],
				page: 1,
				limit: 20
			};
		},
		onShow() {

		},
		onLoad() {
			this.getBanner()
			this.getclassList()
			this.$fun.ajax.post('goods/getListType', {}).then(res => {
				this.typeList = res.data
				this.getList(this.typeList[0].id)
			})
		},
		// 分享好友
		onShareAppMessage() {
			return {
				title: '云算能',
				path: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		// 分享朋友圈
		onShareTimeline() {
			return {
				title: '云算能',
				query: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		onReachBottom(options) {
			if (this.page != 1) {
				this.getList()
			}
		},
		mounted() {

		},
		methods: {
			async getclassList() {
				const res = await this.$fun.ajax.post('index/category', {
					type: 'goods_icon'
				})
				this.classList = res.data
			},
			async getBanner() {
				const res = await this.$fun.ajax.post('goods/getBanner', {})
				this.imageList = res.data
			},
			async getList(id) {
				const res = await this.$fun.ajax.post('goods/getList', {
					type_id: id,
					page: this.page,
					limit: this.limit
				})
				if (res.code == 1) {
					if (res.data.length) {
						this.goodsList = [...this.goodsList, ...res.data]
						this.page++
					} else {
						this.$fun.msg('没有更多了...')
					}

				}

			},
			change(e) {
				this.page = 1
				this.goodsList = []
				this.getList(e.id)
			},
			jump(url) {
				this.$fun.jump(url)
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.container-shop {
		height: 100%;


		.main {
			height: 100%;
			padding-bottom: 150rpx;
		}
	}

	.content {
		.inform {
			margin: 20rpx 30rpx;

			.inform-info {
				display: flex;
				padding: 0 20rpx;
				height: 50rpx;
				border-radius: 10rpx;

				.picture {
					display: flex;
					align-items: center;
					margin-right: 30rpx;

					image {
						width: 34rpx;
						height: 34rpx;
					}
				}

				.info {
					width: 80%;
					height: 100%;

					.swiper {
						height: 500rpx;
						width: 100%;
						// height: 100%;

						.swiper-item {
							display: flex;
							align-items: center;
							width: 100%;
							height: 500rpx;

							img {
								height: 500rpx;
							}

							text {
								font-size: 24rpx;
								color: #333333;
							}
						}
					}
				}
			}
		}

		.classList {
			padding: 20rpx 0;
			margin: 30rpx 50rpx;

			.classItem {
				width: 20%;
				display: flex;
				margin-bottom: 20rpx;
				flex-direction: column;
				align-items: center;

				image {
					width: 104rpx;
					height: 104rpx;
				}

				.text {
					margin-top: 10rpx;
					color: #333333;
					font-size: 24rpx;
					font-family: Microsoft YaHei
				}
			}
		}

		.businessList {
			margin-top: 40rpx;

			.businessItem {
				margin-bottom: 20rpx;
				height: 170rpx;
				// background: #FFFFFF;
				box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.1);
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.l {
					margin-left: 30rpx;
					height: 100%;
					display: flex;
					align-items: center;

					image {
						width: 110rpx;
						height: 110rpx;
					}

					.text_info {
						margin-left: 30rpx;
						display: flex;
						flex-direction: column;
						justify-content: center;

						.title {
							font-size: 28rpx;
							font-family: Microsoft YaHei;
							font-weight: bold;
							color: #333333;
						}

						.text {
							margin-top: 8rpx;
							color: #333333;
							font-size: 24rpx;
						}

					}
				}

				.r {
					margin-right: 27rpx;
					width: 150rpx;
					height: 60rpx;
					// background: #FFFFFF;
					border: 2rpx solid #1D93FF;
					border-radius: 30rpx;
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #1D93FF;
					text-align: center;
					line-height: 60rpx;
				}
			}
		}
	}

	.tabLists {
		width: 100%;
		height: 218rpx;
		padding: 0 10rpx;

		.img {
			height: 100%;
		}

		.text {
			font-weight: 500;
			font-size: 45rpx;
		}
	}

	.shopBox {
		// background-color: #F5F9FF;
		padding: 0 30rpx;

		.shopList {
			// column-count: 2;
			// column-gap: 30rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.shop-item {
				width: 45vw;
				background: rgba(255, 255, 255, 0.2);
				height: 506rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin-top: 15rpx;
				border: 1rpx solid rgba(255, 255, 255, 0.7);

				.shop-title {
					padding: 0 20rpx;

					h3 {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						color: #fff;
						margin-bottom: 20rpx;
					}

					.bottom {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.left {
							color: #FF4201;

							.price {
								font-size: 48rpx;
								font-family: DIN, DIN;
								font-weight: bold;

							}
						}

						.right {
							font-size: 20rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #999999;
						}

					}
				}



			}
		}
	}
</style>